package com.kob.backend.service.impl.product;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.kob.backend.mapper.ProductMapper;
import com.kob.backend.mapper.ShopMapper;
import com.kob.backend.pojo.product;
import com.kob.backend.pojo.shop;
import com.kob.backend.service.product.ProductAddService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;
@Service
public class ProductAddServiceImpl implements ProductAddService {
    @Autowired
    private ProductMapper productMapper;
    @Autowired
    private ShopMapper shopMapper;
    @Override
    public Map<String, String> addproduct(String productname, Double price, Integer inventory, String description,
                                          String photo) {
        Map<String,String>map=new HashMap<>();
        if(productname==null)
        {
            map.put("error_message","商品名不能为空");
            return map;
        }
        if(price==null)
        {
            map.put("error_message","价格不能为空");
            return map;
        }
        if(inventory==null)
        {
            map.put("error_message","库存数不能为空");
            return map;
        }
        if(productname.length()==0)
        {
            map.put("error_message","商品名不能为空");
            return map;
        }
        product this_product = new product(null,productname,price,inventory,description,photo);
        productMapper.insert(this_product);

        map.put("error_message","success");
        return map;
    }


}
